package org.eerbaar.parser;

import org.eerbaar.parser.cky.CKYParser;
import org.eerbaar.parser.core.Grammar;
import org.eerbaar.parser.core.Parser;
import org.eerbaar.parser.core.def.impl.DefaultGrammar;
import org.eerbaar.parser.core.def.impl.DefaultTerminal;
import org.eerbaar.parser.core.exe.SymbolInstance;

public class Factory {

    public static Grammar createGrammar() {
        return new DefaultGrammar();
    }

    public static Parser createParser(Grammar grammar) {
        return new CKYParser(grammar);
    }

    public static SymbolInstance[] createSymbols(String s) {

        SymbolInstance[] r = new SymbolInstance[s.length()];

        int i = 0;
        for (char c : s.toCharArray()) {
            r[i] = new DefaultTerminal("" + c, i, i + 1);
            i++;
        }

        return r;
    }

}
